<?php
/**
 * CategoriasModel
 *  
 * @author rodrigo
 * @version 
 */
class CategoriaModel extends Zwei_Db_Table
{
    /**
     * The default table name 
     */
    protected $_name = 'categoria';
    
    public function select(){
        $select=new Zend_Db_Table_Select($this);
        $select->setIntegrityCheck(false); //de lo contrario no podemos hacer JOIN
        $select->from($this->_name)
                ->joinLeft(array('parent'=>$this->_name), "$this->_name.parent_id = parent.id", array("parent"=>"nombre"))
        ;
        return $select;     
    }
    
    public function selectDistinct(){
    
        $select=new Zend_Db_Table_Select($this);
        $select->distinct()
            ->from($this->_name, array('id','parent'=>'nombre'))
        ;
        
        return $select;             
    }
    
    /**
     * Selecciona diferentes módulos para uso general
     * @return Zend_Db_Table_Select
     */

    public function getCategorias()
    {
        $select=new Zend_Db_Table_Select($this);
        $select->distinct()
        ->from($this->_name, array('id','categoria'=>'nombre'))
        ;
        return $select;
    }
    
    
}
